<!-- 员工分佣报表查询-->
<template>
    <div id="serach">
        <el-form :inline="true" :model="ruleForm" class="demo-form-inline">
            <el-form-item label="报表名称：">
                <el-input placeholder="请输入报表名称" v-model.trim="ruleForm.reportName" maxlength="20"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="searchList" id="monitorEnter">查询</el-button>
             </el-form-item>
        </el-form>

        <el-table :data="tableData" border>
            <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
            <el-table-column label="报表名称" prop="reportName" align="center"></el-table-column>
            <el-table-column label="报表类型" prop="reportType" :formatter="initreportType"  align="center"></el-table-column>
            <el-table-column label="生成时间" prop="createTime" align="center"></el-table-column>
            <el-table-column label="生成进度" prop="progress" align="center">
                 <template slot-scope="scope">
                     {{scope.row.progress==0?'下载中':'已完成'}}
                 </template>
            </el-table-column>
            <el-table-column label="详情" align="center">
                <template slot-scope="scope">
                    <el-button type="text" :disabled="scope.row.progress==0"  @click="downExcelHandle(scope.row)">下载</el-button>
                </template>
            </el-table-column>
        </el-table>

        <div class="pagebar">
            <el-pagination
                    background
                    layout="total, sizes, prev, pager, next"
                    :current-page.sync="ruleForm.pageNum"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="ruleForm.pageSize"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :total="totalSize">
            </el-pagination>
        </div>

    </div>
</template>
<script>
    import api from '@/api/apiPath'
    export default {
        name: 'searchReport',
        title:'员工分佣报表查询',
        data() {
            return {
                ruleForm: {
                    reportName: undefined,
                    pageNum: 1,
                    pageSize: 10,
                },
                totalSize: 0,
                tableData: [],
            }
        },

        methods: {
            initreportType(row, column, cellValue, index){
                if (cellValue == 1) {
                    return  '交易佣金'
                }else if (cellValue == 2) {
                    return '业绩激励'
                }else if (cellValue == 3) {
                    return '利润激励'
                }else{
                    return '市场佣金'
                }
            },
            searchList() {
                this.ruleForm.pageNum = 1
                this.getlist()
            },
            handleCurrentChange() {
                this.getlist()
            },
            handleSizeChange(val) {
                this.ruleForm.pageSize = val
                this.getlist();
            },
            downExcelHandle(val) {
                if ( val.fileUrl == '') {
                    this.$message({
                        message: '链接为空，请联系后台人员',
                        type: 'warning'
                    });
                    return
                }
                let downnode = document.createElement('a')
                let href = val.fileUrl
                downnode.href = href
                document.getElementById('serach').appendChild(downnode)
                downnode.click()
            },
            getlist() {
                this.axios.post(api.REPORTRECORDLIST, this.ruleForm).then((res) => {
                    this.tableData = res.data.data.list;
                    this.totalSize = res.data.data.total;
                })
            }
        },
        activated(){
           this.searchList()
        },
        created() {
            this.getlist()
        }
    }

</script>


<style lang="stylus" scoped>
</style>
